export class Const {
  static commonUrl = '/banksearchSystem';
  // static commonUrl = '';
  static inputNumMax = 99999;
  static formLayout = {
    labelCol: {
      span: 6,
    },
    wrapperCol: {
      span: 14,
    }
  };
  static formLayoutTwo = {
    labelCol: {
      span: 3,
    },
    wrapperCol: {
      span: 19,
    }
  };
  static format = "YYYY-MM-DD";
  static tooltipColor = 'rgba(0, 0, 0, .45)';
  static dealMap = (arr) => {
    let obj = {};
    for (let item of arr) {
      obj[item.value] = {
        text: item.label
      }
    };
    return obj;
  };
  // 航班号处理
  static formatFlightNo = val => {
    if (!val) {
      return '';
    } else if (val.length < 3 || /^\D/.test(val)) {
      return ''.toUpperCase.call(val);
    } else if (/^\d{2}/.test(val)) {
      return `3U${val}`;
    } else {
      return val;
    }
  };
  // 格式化大写字母
  static toUpperCaseFormat = val => {
    if (val) {
      return val.toUpperCase();
    } else {
      return val;
    }
  };
  // 证件类型
  static idTypeListForSearch = [
    { label: '身份证', value: 'NI' },
    { label: '护照', value: 'PP,PSPT' },
    // { label: '护照', value: 'PSPT' },
    { label: '军官证', value: 'ID' },
    { label: '其他', value: 'UU' }
  ];
  static idTypeList = [
    { label: '身份证', value: 'NI' },
    { label: '护照', value: 'PP' },
    { label: '护照', value: 'PSPT' },
    { label: '军官证', value: 'ID' },
    { label: '其他', value: 'UU' }
  ];
  static idTypeMap = {
    'NI': { text: '身份证' },
    'PP': { text: '护照' },
    'PSPT': { text: '护照' },
    'ID': { text: '军官证' },
    'UU': { text: '其他' },
    'CC': { text: '信用卡' },
    'PP,PSPT': { text: '护照' },
  };
  // 速运类型 掉条、漏运、错运、退回始发站、内部托运、多收转速运、其他
  static suYunTypeList = [
    { label: '掉条', value: '1' },
    { label: '漏运', value: '2' },
    { label: '错运', value: '3' },
    { label: '退回始发站', value: '4' },
    { label: '内部托运', value: '5' },
    { label: '多收转速运', value: '6' },
    { label: '其他', value: '7' },
  ];
  static suYunTypeMap = Const.dealMap(Const.suYunTypeList);
  // 结案状态 0处理中 1已结案 2待处理 3已作废
  static jieanStatusList = [
    { label: '处理中', value: '0' },
    { label: '已结案', value: '1' },
    { label: '待处理', value: '2' },
    { label: '已作废', value: '3' },
    // { label: 'H5草稿箱', value: '4' },
  ];
  static jieAnStatusMap = Const.dealMap(Const.jieanStatusList);
  // 是否通知
  static isNoticeList = [
    { label: '否', value: '0' },
    { label: '是', value: '1' },
  ];
  static isNoticeMap = Const.dealMap(Const.isNoticeList);
  static setIsNeedGetList = (type) => {
    let obj = {};
    if (sessionStorage.getItem('isNeedGetBaggageList')) {
      obj = JSON.parse(sessionStorage.getItem('isNeedGetBaggageList'));
      obj[type] = 1;
    } else {
      obj[type] = 1;
    }

    sessionStorage.setItem('isNeedGetBaggageList', JSON.stringify(obj));
  };
  static getIsNeedGetList = (type) => {
    if (sessionStorage.getItem('isNeedGetBaggageList')) {
      let obj = JSON.parse(sessionStorage.getItem('isNeedGetBaggageList'));
      if (+obj[type] === 1) {
        obj[type] = 0;
        sessionStorage.setItem('isNeedGetBaggageList', JSON.stringify(obj));
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  };
  static accidentReasonList = [
    { label: '错运', value: 1 },
    { label: '丢失', value: 2 },
    { label: '内物缺失', value: 3 },
    { label: '其他原因', value: 4 },
    { label: '错挂', value: 5 },
    { label: '脱牌', value: 6 },
    { label: '漏装', value: 7 },
    { label: '卡带', value: 8 },
    { label: '减载', value: 9 },
    { label: '安扣', value: 10 },
    { label: '错提', value: 11 },
    { label: '错卸', value: 12 },
    { label: '行李破损', value: 13 },
  ];
  static accidentReasonMap = Const.dealMap(Const.accidentReasonList);
  static permissionsType = new Map()
    .set(1, 'damagedLuggage')
    .set(2, 'lessLuggage')
    .set(3, 'moreLuggage')
    .set(6, 'internalMissingLuggage')
    .set(7, 'outDamagedLuggage')
    .set(8, 'outLuggage');
}
